// 纯净基础 插件

string author = "Live";
string pluginName = "纯净 基础插件";
string version = "0.1";

// 插件初始化
void OnPluginInit()
{
    // 设置插件信息
    PluginData::SetAuthor(author);
    PluginData::SetName(pluginName);
    PluginData::SetVersion(version);

    // 加载后提示信息
    ThePresident.InfoFeed("插件:"+pluginName+"| 版本:"+version+"| 作者:"+author,false);
	
	// 当玩家说
    Events::Player::PlayerSay.Hook( @PlayerSay );
	// 当玩家连接后
    Events::Player::OnPlayerConnected.Hook( @OnPlayerConnected );
	
	Engine.RunConsoleCommand( "mapcyclefile onlyFlatLine.txt" );
	
	ThePresident_OnMapStart();

}

// 地图开始
void ThePresident_OnMapStart(){
    // 服务器中文名
    Engine.RunConsoleCommand( "hostname [CN.Live] 纯净 | 噩梦防守 flatline QQ群392635015");
    // 设置难度
    Engine.RunConsoleCommand( "Difficulty 4");
    // 设置无法投票更改难度
    Engine.RunConsoleCommand( "sv_vote_issue_change_difficulty_allowed 0" );
	// 仅AI丧尸（玩家死亡不会变丧尸）
    Engine.RunConsoleCommand( "cg_zombie_ai_only 1" );
    // 无感染
    Engine.RunConsoleCommand( "cg_infection_disabled 1" );
	// 设置普通僵尸伤害量
	Engine.RunConsoleCommand( "cf_zombie_dealsamedamage 1" );
	// 设置防守BOSS
	Engine.RunConsoleCommand( "cf_enable_bosses 3" );
	// 设置僵尸生命值
	Engine.RunConsoleCommand( "cf_zombie_healthincrease_type 2" );
    // 执行回合开始
    ThePresident_OnRoundStart();
	
}

// 回合开始
void ThePresident_OnRoundStart()
{
	
}

// 当玩家连接后
HookReturnCode OnPlayerConnected(CTerrorPlayer@ pPlayer)
{
	Chat.PrintToChat(pPlayer,"当前服务器为纯净防守服，设置信息:\n{hotpink}普通僵尸伤害与精英一致、一半时开始刷BOSS怪、僵尸血量随玩家人数增加");
	return HOOK_CONTINUE;
}


HookReturnCode PlayerSay(CTerrorPlayer@ pPlayer, CASCommand@ pArgs){
    string arg = pArgs.Arg( 1 );
	string arg1 = "";
	string arg2 = "";

	// 切分字符串(这样就可以用空格传一个命令参数了)
	int subIndex = arg.findFirst(" ",0);
	if(not (subIndex < 0)){
		arg1 = arg.substr(0,subIndex);
		arg2 = arg.substr(subIndex+1,-1);
		//Chat.PrintToChat(all,""+arg1+"|"+arg2);
	}else{
		arg1 = arg;
	}
	
	if(arg1 == "!give"){
		if( AdminSystem.AdminExist(pPlayer) ){
			if( arg2!="" )
				pPlayer.GiveWeapon(arg2);
		}
	}else if(arg1 == "!fh"){
		if( AdminSystem.AdminExist(pPlayer) ){
			if( not Utils.StrEql( arg2, "" ) ){
				if( arg2 == "all" ){
					array<int> playerList = Utils.CollectPlayers();
					for(uint i=0;i<playerList.length();i++){
						CTerrorPlayer@ player = ToTerrorPlayer(playerList[i]);
						if(not (player.GetTeamNumber() == TEAM_SURVIVOR)){
							// 修改被复活玩家的游戏阵营
							pPlayer.ChangeTeam( TEAM_SURVIVOR );
							// 复活玩家
							pPlayer.Respawn();
						}
					}
					Chat.PrintToChat(all,"管理员复活了所有玩家");
				}else{
					CTerrorPlayer@ splayer = ToTerrorPlayer( parseInt(arg2,10,0) );
					if(splayer is null) return HOOK_CONTINUE;
					// 修改被复活玩家的游戏阵营
					splayer.ChangeTeam( TEAM_SURVIVOR );
					// 复活玩家
					splayer.Respawn();
					Chat.PrintToChat(all,"{hotpink}管理员使用命令复活了["+splayer.GetPlayerName()+"]");
				}
			}else{
				// 修改被复活玩家的游戏阵营
				pPlayer.ChangeTeam( TEAM_SURVIVOR );
				// 复活玩家
				pPlayer.Respawn();
			}
		}
	}else{
        // 玩家专属称号
        if( pPlayer.GetSteamID64() == "76561199221153384"){
            Chat.PrintToChat(all,"{deeppink}[服主]{lime}[Contagion插件作者] "+pPlayer.GetPlayerName()+" : "+arg);
        }else if( pPlayer.GetSteamID64() == "76561198311292986" ){
            Chat.PrintToChat(all,"{hotpink}[玩法策划]{unique}[赞助VIP] "+pPlayer.GetPlayerName()+" : "+arg);
            // 76561199149736894 聆听夏的味道 76561199405413662 nmsl 76561198135257879 雪ノ下 樹海♬ 76561198322158804 奇迹行者
        }else if( pPlayer.GetSteamID64() == "76561199149736894" || pPlayer.GetSteamID64() == "76561199405413662" || pPlayer.GetSteamID64() == "76561198135257879" || pPlayer.GetSteamID64() == "76561198322158804"){
            Chat.PrintToChat(all,"{unique}[赞助VIP] "+pPlayer.GetPlayerName()+" : "+arg);
        }else if( pPlayer.GetSteamID64() == "76561198884797182" ){
            Chat.PrintToChat(all,"{unique}[鸽子白] "+pPlayer.GetPlayerName()+" : "+arg);
        }else{
            Chat.PrintToChat(all,pPlayer.GetPlayerName()+" : "+arg);
        }
    }

	return HOOK_HANDLED;

}
